package cj.web.config.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.config.domain.Category;

/**
 * 
 * @author 
 *
 */
@DAO
public interface CategoryDAO{
	
	@SQL("SELECT * FROM category WHERE deleteFlag=1 and status=1 order by orderNo ")
    List<Category> queryAll();
	
	@SQL("SELECT * FROM category WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Category> query(@SQLParam("t") Category category);
	
	@SQL("SELECT COUNT(1) FROM category WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ")
    int querySize(@SQLParam("t") Category category);
    
    @SQL("SELECT * FROM category WHERE id=:1 ")
    Category queryById(int id);
    
    @SQL("INSERT INTO category (pId,name,descs,value,status,orderNo,deleteFlag,createUser,createAT,updateUser,updateAT) VALUES (:t.pId,:t.name,:t.descs,:t.value,1,:t.orderNo,1,:t.createUser,now(),:t.updateUser,now()) ")
    void create(@SQLParam("t") Category category);
	
	@SQL("UPDATE category SET pId=:t.pId,name=:t.name,descs=:t.descs,value=:t.value,orderNo=:t.orderNo,updateUser=:t.updateUser,updateAT=now() WHERE id=:t.id ")
    void update(@SQLParam("t") Category category);
    
    @SQL("UPDATE category SET deleteFlag=0 WHERE id=:1 ")
    void deleteById(int id);
}